#copy from:http://www.python-forum.org/pythonforum/viewtopic.php?t=10631&f=2=10631&f=2
# play a MP3 or MIDI music file using module pygame
# (does not create a GUI frame in this case)
# pygame is free from: http://www.pygame.org/
# Tested with pygame-1.8.0 by:  Ene Uran

import pygame

def play_music(music_file):
    """
    stream music with mixer.music module in blocking manner
    this will stream the sound from disk while playing
    """
    clock = pygame.time.Clock()
    try:
        pygame.mixer.music.load(music_file)
        print "Music file %s loaded!" % music_file
    except pygame.error:
        print "File %s not found! (%s)" % (music_file, pygame.get_error())
        return
    pygame.mixer.music.play(-1,0)
    while pygame.mixer.music.get_busy():
        # check if playback has finished
        clock.tick(30)

def run():
    # pick a MP3 or MIDI music file you have ...
    # (if not in working folder, use full path)
    music_file = r'E:\music\Lenka-Like-a-Song.mp3'
    #music_file = "ChancesAre.mid"

    # set up the mixer
    freq = 44100     # audio CD quality
    bitsize = -16    # unsigned 16 bit
    channels = 2     # 1 is mono, 2 is stereo
    buffer = 2048    # number of samples (experiment to get right sound)
    pygame.mixer.init(freq, bitsize, channels, buffer)

    # optional volume 0 to 1.0
    pygame.mixer.music.set_volume(0.75)

    try:
        play_music(music_file)
    except KeyboardInterrupt:
        # if user hits Ctrl/C then exit
        # (works only in console mode)
        pygame.mixer.music.fadeout(1000)
        pygame.mixer.music.stop()
        raise SystemExit
